package com.baizhi.listx;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 将集合转成数组
 */
public class ListDemo05 {
    public static void main(String[] args) {
        List<String> list =  new ArrayList<>();
        list.add("one");
        list.add("two");
        list.add("three");
        list.add("four");
        list.add("five");
        System.out.println(list);


        /**
         * Object[] toArray()
         */
//        Object[] objects = list.toArray();
//        System.out.println(objects);
//        System.out.println(Arrays.toString(objects));

        String[] strings = list.toArray(new String[list.size()]);
        System.out.println(Arrays.toString(strings));

    }
}
